blog

Home / DeveloperSection / Blogs / LINQ in .NET

LINQ in .NET

Amit Singh 4522 17-Nov-2010

LINQ is a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

In LINQ we used same format as SQL but some difference like positioning, style in Select, where etc. We use the System.Linq namespace.
Benefits of LINQ:
  • It provides rich Meta data.
  • Compile-time syntax checking
  • LINQ is static typing and provide intelliSence (previously available in imperative code).
  • It provides query in concise way.
We create LINQ between LINQ to object, LINQ to XML, LINQ to SQL.

Example

using System.Collections.Generic;
using System.Linq;
string[] Country = { "India", "SriLanka", "China",  "Nepal", "Newzeland", "South Africa","America", "England" };
//In this section using LINQ Query IEnumerable<string> query = from s in Country
  where s.Length == 5
  orderby s 
  select s.ToUpper();
foreach (string item in query) Console.WriteLine(item);



Updated 18-Sep-2014

Leave Comment

Comments

Liked By